package Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author chihb
 * @create-time 2024/7/4 1:23
 * @description
 */
public class demo1 {
    public static void main(String[] args) throws ParseException {
        String date="2015-10-20";
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date d=sdf.parse(date);
        Calendar c=Calendar.getInstance();
        c.setTime(d);
        int year=c.get(Calendar.YEAR);
        int month=c.get(Calendar.MONTH);
        int day=c.get(Calendar.DAY_OF_MONTH);
        int xq=c.get(Calendar.DAY_OF_WEEK);
        int djt=c.get(Calendar.DAY_OF_YEAR);
        String WeekDay="";
        switch (xq){
            case 1:
                WeekDay="星期天";
                break;
            case 2:
                WeekDay="星期一";
                break;
            case 3:
                WeekDay="星期二";
                break;
            case 4:
                WeekDay="星期三";
                break;
            case 5:
                WeekDay="星期四";
                break;
            case 6:
                WeekDay="星期五";
                break;
            case 7:
                WeekDay="星期六";
                break;
        }
        System.out.println(year+"年-"+(month+1)+"月-"+day+"日 是"+WeekDay+",是"+year+"年的第"+djt+"天");
    }
}
